// Code generated by bpf2go; DO NOT EDIT.
//go:build 386 || amd64

package tracer

import (
	"bytes"
	_ "embed"
	"fmt"
	"io"

	"github.com/cilium/ebpf"
)

type tcpretransEvent struct {
	Saddr       [16]uint8
	Daddr       [16]uint8
	Timestamp   uint64
	Af          uint16
	Dport       uint16
	Sport       uint16
	State       uint8
	Tcpflags    uint8
	Reason      uint32
	Netns       uint32
	ProcCurrent struct {
		MountNsId uint64
		Pid       uint32
		Tid       uint32
		Uid       uint32
		Gid       uint32
		Task      [16]uint8
	}
	ProcSocket struct {
		MountNsId uint64
		Pid       uint32
		Tid       uint32
		Uid       uint32
		Gid       uint32
		Task      [16]uint8
	}
	_ [8]byte
}

// loadTcpretrans returns the embedded CollectionSpec for tcpretrans.
func loadTcpretrans() (*ebpf.CollectionSpec, error) {
	reader := bytes.NewReader(_TcpretransBytes)
	spec, err := ebpf.LoadCollectionSpecFromReader(reader)
	if err != nil {
		return nil, fmt.Errorf("can't load tcpretrans: %w", err)
	}

	return spec, err
}

// loadTcpretransObjects loads tcpretrans and converts it into a struct.
//
// The following types are suitable as obj argument:
//
//	*tcpretransObjects
//	*tcpretransPrograms
//	*tcpretransMaps
//
// See ebpf.CollectionSpec.LoadAndAssign documentation for details.
func loadTcpretransObjects(obj interface{}, opts *ebpf.CollectionOptions) error {
	spec, err := loadTcpretrans()
	if err != nil {
		return err
	}

	return spec.LoadAndAssign(obj, opts)
}

// tcpretransSpecs contains maps and programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcpretransSpecs struct {
	tcpretransProgramSpecs
	tcpretransMapSpecs
}

// tcpretransSpecs contains programs before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcpretransProgramSpecs struct {
	IgTcpretrans *ebpf.ProgramSpec `ebpf:"ig_tcpretrans"`
}

// tcpretransMapSpecs contains maps before they are loaded into the kernel.
//
// It can be passed ebpf.CollectionSpec.Assign.
type tcpretransMapSpecs struct {
	Events        *ebpf.MapSpec `ebpf:"events"`
	GadgetSockets *ebpf.MapSpec `ebpf:"gadget_sockets"`
}

// tcpretransObjects contains all objects after they have been loaded into the kernel.
//
// It can be passed to loadTcpretransObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcpretransObjects struct {
	tcpretransPrograms
	tcpretransMaps
}

func (o *tcpretransObjects) Close() error {
	return _TcpretransClose(
		&o.tcpretransPrograms,
		&o.tcpretransMaps,
	)
}

// tcpretransMaps contains all maps after they have been loaded into the kernel.
//
// It can be passed to loadTcpretransObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcpretransMaps struct {
	Events        *ebpf.Map `ebpf:"events"`
	GadgetSockets *ebpf.Map `ebpf:"gadget_sockets"`
}

func (m *tcpretransMaps) Close() error {
	return _TcpretransClose(
		m.Events,
		m.GadgetSockets,
	)
}

// tcpretransPrograms contains all programs after they have been loaded into the kernel.
//
// It can be passed to loadTcpretransObjects or ebpf.CollectionSpec.LoadAndAssign.
type tcpretransPrograms struct {
	IgTcpretrans *ebpf.Program `ebpf:"ig_tcpretrans"`
}

func (p *tcpretransPrograms) Close() error {
	return _TcpretransClose(
		p.IgTcpretrans,
	)
}

func _TcpretransClose(closers ...io.Closer) error {
	for _, closer := range closers {
		if err := closer.Close(); err != nil {
			return err
		}
	}
	return nil
}

// Do not access this directly.
//
//go:embed tcpretrans_bpfel_x86.o
var _TcpretransBytes []byte
